$(document).ready(function(){
  
  $('#update').click(function(){
    $(function() {
      $("#updateConfirmation").dialog({
        resizable: false,
        height:340,
        modal: true,
        buttons: {
          "Update": function() {
            $( this ).dialog( "close" );
            alert('Please, white untill the page will refresh itself...');
            $.ajax({
              url: 'searchItems.php',
              dataType: 'json',
              success: function(response){
                alert(response);
                window.location.reload();
              },
              error: function(error){
                alert('Looks like some errors occured, please, try again later and sorry for inconveniences...')
              }
            });
          },
          Cancel: function() {
            $( this ).dialog( "close" );
          }
        }
      });
    });
  });
});